import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { IPage, IBookRecord, IBookRecordVo } from "./types";

/* 查询预约记录列表 */
export function getPageBookRecordAPI(
  queryParams?: IPage
): AxiosPromise<PageResult<IBookRecord[]>> {
  return request({
    url: "/bookRecord/page",
    method: "get",
    params: queryParams,
  });
}
/* 根据id查询预约记录对象 */
export function getFormBookRecordAPI(id: number): AxiosPromise<IBookRecord> {
  return request({
    url: `/bookRecord/${id}/form`,
    method: "get",
  });
}

export function getMyRecordAPI(): AxiosPromise<IBookRecordVo[]> {
  return request({
    url: `/bookRecord/my`,
    method: "get",
  });
}

/**
 * 添加预约记录
 *
 * @param data
 */
export function addBookRecordAPI(data: any) {
  return request({
    url: "/bookRecord",
    method: "post",
    data: data,
  });
}

/**
 * 修改预约记录
 *
 * @param id
 * @param data
 */
export function updateBookRecordAPI(id: number, data: IBookRecord) {
  return request({
    url: "/bookRecord/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 删除预约记录
 *
 * @param ids
 */
export function deleteBookRecordAPI(ids: number) {
  return request({
    url: "/bookRecord/" + ids,
    method: "delete",
  });
}
